package com.teach.shape1;

import java.util.Scanner;

/**
 * 椭圆
 * @author J.L.Zhou
 *	jlzhou.top 版权所有
 */
public class Ellipse {
	private static final String NAME = "椭圆形";
	/**
	 * 宽
	 */
	private float a;
	/**
	 * 高
	 */
	private float b;
	
	/**
	 * 周长
	 */
	private float perimeter;
	
	/**
	 * 面积
	 */
	private float area;

	public void input(Scanner sc) {
		System.out.println("输入"+NAME+"的最长半径: ");
		a = sc.nextFloat();

		System.out.println("输入"+NAME+"的最短半径: ");
		b = sc.nextFloat();
		
		if(b>a){
			float temp = a;
			a = b;
			b = temp;
		}
		
		perimeter = (float)(2*Math.PI*b+4*(a-b));
		area = (float)(Math.PI*a*b);
	}
	

	/**
	 * 获取周长
	 * @return 周长
	 */
	public float getPerimeter(){
		return perimeter;
	}

	/**
	 * 获取面积
	 * @return
	 */
	public float getArea(){
		return area;
	}

	/**
	 * 打印基本信息
	 */
	public void show() {
		System.out.format("%s\t周长：%.2f\t面积：%.2f\t半径：%.2f，%.2f\n",NAME,perimeter,area,a,b);

	}

	
	
	public float getA() {
		return a;
	}


	public void setA(float a) {
		this.a = a;
	}


	public float getB() {
		return b;
	}


	public void setB(float b) {
		this.b = b;
	}


	public static void main(String[] args) {
		Ellipse rectangle = new Ellipse();
		rectangle.input(new Scanner(System.in));
		rectangle.show();
	}

}
